<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
    <title>项目进度情况</title>
    <meta name="decorator" content="form"/>
    <html:css name="bootstrap-fileinput" />
    <html:css name="simditor,jquery-select2" />
    <html:js name="jquery-select2"/>
    <link href="${staticPath}/project/laydate-v5.0.9/theme/default/laydate.css" rel="stylesheet">
	<script  src="${staticPath}/project/laydate-v5.0.9/laydate.js" type="text/javascript"></script>
	<!-- 处理本系统缺图标问题 -->
	<style>
	 .laydate-icon {
            background-image: none;
            border-color: white;
        }
	</style>
</head>

<body class="white-bg"  formid="xmglProjectProgressForm">
    <form:form id="xmglProjectProgressForm" modelAttribute="data" action="${adminPath}/xmgl/xmglprojectprogress/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="project"/>
		<table  class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>项目名称:</label>
		            </td>
					<td class="width-35">
						<form:select path="projectID" htmlEscape="false" class="form-control"        />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>计划值:</label>
		            </td>
					<td class="width-35">
						<form:input path="plan" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>实际值:</label>
		            </td>
					<td class="width-35">
						<form:input path="fact" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>月分:</label>
		            </td>
					<td class="width-35">
						<form:input path="termMonth" autocomplete="off"  htmlEscape="false" class="form-control layer-date" placeholder="YYYY-MM" />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>附件:</label>
		            </td>
					<td class="width-35" colspan="3">
					   <input id="relateTable1" type="hidden" value="xmgl_project_progress"/>
   						<!-- relateFeild1 该值对多控件文件上传需要唯一标识否则界面样式异常，注：多文件上传集成框架使用不到该值，需要使用url参数传值 -->
						<input id="relateFeild1" type="hidden" value="files" nested="false" />
						<form:fileinput buttonText="选择文件" saveType="billId" fileActionSettings="{showRemove: true,showUpload: false}"
   isFormSubmit="true" uploadExtraFieldData="relateTable1,relateFeild1" path="files" extend="bmp,gif,jpg,jpeg,png"	
   initUrl="${adminPath}/sys/attachment/list?relateTable=xmgl_project_progress&relateFeild=files"
   uploadUrl="${adminPath}/sys/attachment/upload?relateTable=xmgl_project_progress&relateFeild=files"
   showUpload="false" showRemove="false" nested="false"  autoUpload="false" uploadAsync="false"
   htmlEscape="false" class="form-control"   fileInputWidth="100px"  fileInputHeight="100px"/>
   <label class="Validform_checktip"></label>
						<label class="Validform_checktip"></label>
					</td>
		  		</tr>
		      
		   </tbody>
		</table>   
	</form:form>
<html:js name="bootstrap-fileinput" />
<html:js name="simditor" />
<script>
var project="";
$(function() {

	  //年月选择器
	  laydate.render({
	    elem: '#termMonth'
	    ,type: 'month'
	    //,range: true
	    ,trigger: 'click'
	    //,max: -30
	    ,done: function(value, date, endDate){
	      console.log(value, date, endDate);
	    }
	    ,change: function(value, date, endDate){
	      this.elem.val(value)
	    }
	  });
	  
	getSelectProject(); 
	
})


//绑定项目
function getSelectProject() {
	project = $("#project").val();
	$("#projectID").change(function(){
		debugger
		$("#project").val($("#projectID").find("option:selected").text());
		console.log("project:"+$("#project").val());
	});
    $.ajax({
        type: "POST",
        url: "${adminPath}/sbfb/eqprojectinfo/ajaxList",
        data: {'page.size':300,queryFields:'code,name,'},
        dataType: "json",
        success: function (data) {
            var select = $("#projectID");
        	
            select.empty();
        	if(data && data.total>0){            	
                var str = "<option value=''>请选择</option>";
                select.append(str);
                if (null != data && data.results.length > 0) {
                    $.each(data.results, function (i, item) {
                        if(project && item.id==project){
                            str = "<option value=" + item.id + " selected>" + item.name + "</option>";
                            select.append(str);
                            var event = document.createEvent("HTMLEvents");
                            event.initEvent("change", true, true);
                            document.querySelector("#projectID").dispatchEvent(event);
                        }else{
                            str = "<option value=" + item.id + ">" + item.name + "</option>";
                            select.append(str);
                        }
                    });
                } else {
                    console.log("data is null");
                }
        	}

        }
    });
}


</script>
</body>
</html>